package cn.stylefeng.guns.base.utils;

import cn.hutool.core.date.DateUtil;

import java.util.Calendar;
import java.util.Date;

/**
 * @program: football_manage
 * @description: 日期工具类
 * @author: xiesm
 * @create: 2021-03-01 13:45
 **/
public class FootDateUtil {

    public static Date getWeekMonday(int week, int year) {
        return DateUtil.beginOfWeek(getCalendar(week, year)).getTime();
    }

    public static Date getWeekSunday(int week, int year) {
        return DateUtil.endOfWeek(getCalendar(week, year)).getTime();
    }

    private static Calendar getCalendar(int week, int year) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, year);
        Calendar calendar = DateUtil.beginOfYear(cal);
        calendar.add(Calendar.DATE, week * 7);
        return calendar;
    }
}
